import js from '@eslint/js'
import globals from 'globals'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

// export default [
//   { ignores: ['**/node_modules', '**/dist', '**/out'] },
//   eslint,
//   eslintPluginReact.configs.flat.recommended,
//   eslintPluginReact.configs.flat['jsx-runtime'],
//   {
//     settings: {
//       react: {
//         version: 'detect'
//       }
//     }
//   },
//   {
//     files: ['**/*.{js,jsx}'],
//     plugins: {
//       'react-hooks': eslintPluginReactHooks,
//       'react-refresh': eslintPluginReactRefresh
//     },
//     rules: {
//       ...eslintPluginReactHooks.configs.recommended.rules,
//       ...eslintPluginReactRefresh.configs.vite.rules,
//       ...js.configs.recommended.rules,
//       ...react.configs.recommended.rules,
//       ...react.configs['jsx-runtime'].rules,
//       ...reactHooks.configs.recommended.rules,
//       //   就是添加这个，禁用prop-types校验
//       'react/prop-types': 0,
//       //   添加这个，禁用prop-display-name校验
//       'react/display-name': 0,
//       'react/jsx-no-target-blank': 'off',
//       'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
//     }
//   },
//   eslintConfigPrettier
// ]
export default [
  { ignores: ['dist'] },
  {
    files: ['**/*.{js,jsx}'],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser,
      parserOptions: {
        ecmaVersion: 'latest',
        ecmaFeatures: { jsx: true },
        sourceType: 'module'
      }
    },
    settings: { react: { version: '18.3' } },
    plugins: {
      react,
      'react-hooks': reactHooks,
      'react-refresh': reactRefresh
    },
    rules: {
      ...js.configs.recommended.rules,
      ...react.configs.recommended.rules,
      ...react.configs['jsx-runtime'].rules,
      ...reactHooks.configs.recommended.rules,
      'react/jsx-no-target-blank': 'off',
      'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
    }
  }
]
